package com.fang.transfer.file.service;

import com.fang.transfer.file.common.model.TransferFileRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.concurrent.ConcurrentHashMap;

@Service
@Slf4j
public class FileSendRequestService {

    private ConcurrentHashMap<String, TransferFileRequest> sendFileRequestMap = new ConcurrentHashMap();

    public void addRequest(TransferFileRequest request) {
        sendFileRequestMap.put(request.getId(), request);
    }


    public TransferFileRequest getById(String id) {
        TransferFileRequest request = sendFileRequestMap.get(id);
        if (request == null) {
            throw new RuntimeException("不合法请求");
        }
        return request;
    }

}
